package leetcode.code0676;

import java.math.BigDecimal;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

import leetcode.helper.H;

public class MagicDictionary {

	Set<String> set;

	public MagicDictionary() {
		set = new HashSet<>();
	}

	public void buildDict(String[] dictionary) {
		for (String string : dictionary) {
			set.add(string);
		}
	}

	public boolean search(String searchWord) {
		char[] cs = searchWord.toCharArray();
		for (int i = 0; i < cs.length; i++) {
			int c = cs[i] - 'a';
			for (int j = 1; j < 26; j++) {
				int w = (c + j) % 26;
				cs[i] = (char) (w + 'a');
				if (set.contains(new String(cs)))
					return true;
			}
			cs[i] = (char) (c + 'a');
		}
		return false;
	}

	public static void main(String[] args) {
		MagicDictionary md = new MagicDictionary();
		md.buildDict(H.str2array2("[a]"));
//		System.out.println(md.search("b"));
//		System.out.println(md.search("a"));
//		BigDecimal bd1 = new BigDecimal(10);
//		BigDecimal bd2 = new BigDecimal(10);
//		BigDecimal bd3 = new BigDecimal(20);
//		BigDecimal bd4 = new BigDecimal(5);
//		System.out.println(bd1.compareTo(bd2));
//		System.out.println(bd1.compareTo(bd3));
//		System.out.println(bd1.compareTo(bd4));
//		System.out.println(bd4.compareTo(bd1));
		String str = "1ab";
//		System.out.println(str.indexOf("a"));
//		System.out.println(str.indexOf("b"));
		System.out.println(str.compareTo("0ab"));
		System.out.println(str.compareTo("1ab"));
		System.out.println(str.compareTo("2ab"));
		System.out.println(str.compareTo(""));
		float ans = 1f * 10 / 20;
		System.out.println(ans);
		System.out.println(1d);
		System.out.println(1f);
	}
}
